{% macro saisonselect(activeSaison) %}
<label for="saison">Saison: </label>
<select id="saison" name="saison">
    <option {% if not(activeSaison) %}selected{% endif %} value="">
        Choisissez une saison
    </option>

    {% for i in 0..5 %}
    <option
         {% if activeSaison[0] == (2013 - i - 1) %}selected{% endif %}
         value="{{2013 - i - 1}}-{{2013 - i}}">
        {{2013 - i - 1}}-{{2013 - i}}
    </option>
    {% endfor %}
</select>
{% endmacro %}

{% macro clubselect(selectedClub, clubs) %}
<label for="club">Club: </label>
<select id="club" name="club">
    {% for club in clubs %}
    <option
         {% if selectedClub == club['Nom_Club'] %}selected{% endif %}
         value="{{club['Nom_Club']}}">
        {{club['Nom_Club']}}
    </option>
    {% endfor %}
</select>
{% endmacro %}

{% macro equipeselect(equipes, name='equipe', activeEquipe='') %}
<div class="control-group">
    <label class="control-label" for="select-{{equipe}}">{{ lang(name) }}: </label>
    <div class="controls">
        <select id="select-{{name}}" name="{{name}}">
            {% for equipe in equipes %}
            <option
                 {% if activeEquipe == equipe['Numero_Equipe'] %}selected{% endif %}
                 value="{{equipe['Numero_Equipe']}}">
                {{equipe['_Nom_Abs']}}
            </option>
            {% endfor %}
        </select>
    </div>
</div>
{% endmacro %}


{% macro select(name, label, objs, valuekey, labelkey, selected) %}
<label for="{{name}}">{{Label}}</label>
<select id="{{name}}" name="{{name}}">
    {% for o in objs %}
    <option
         {% if selected == o[valuekey] %}selected{% endif %}
         value="{{o[valuekey]}}">
        {{o[labelkey]}}
    </option>
    {% endfor %}
</select>
{% endmacro %}

{% macro dateselect(name='date', label='Date: ', prefill='') %}
<label for="input-{{name}}">{{label}}</label>
<div class="input-append date" id="dp3" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
    <input type="text"
           class="span2 datepicker"
           size="16"
           id="input-{{name}}"
           name="{{name}}"
           value="{{prefill}}" />
</div>
{% endmacro %}

{% macro dateselect(name='date', label='Date: ', prefill='') %}
<label for="input-{{name}}">{{label}}</label>
<div class="input-append date" id="dp3" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
    <input type="text"
           class="span2 datepicker"
           size="16"
           id="input-{{name}}"
           name="{{name}}"
           value="{{prefill}}" />
</div>
{% endmacro %}

{% macro hordateselect(name='date', label='Date: ', prefill='') %}
<div class="control-group">
    <label class="control-label" for="input-{{name}}">{{label}}</label>
    <div class="controls">
        <div class="input-append date" id="dp3" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
            <input type="text"
                   class="span2 datepicker"
                   size="16"
                   id="input-{{name}}"
                   name="{{name}}"
                   value="{{prefill}}" />
        </div>
    </div>
</div>
{% endmacro %}

{% macro dump(obj) %}
<dl class="dl-horizontal">
    {% for key, value in obj %}
    <dt>{{lang(key)}}</dt><dd>{{value}}</dd>
    {% endfor %}
</dl>
{% endmacro %}

{% macro dumptable(tbl, skip = []) %}
{% if tbl|length > 0 %}
<table class="table">
    <thead>
        <tr>
            {% for key, _ in tbl[0] %}
            {% if key not in skip %}
            <th>{{lang(key)|raw}}</th>
            {% endif %}
            {% endfor %}
        </tr>
    </thead>

    <tbody>
        {% for row in tbl %}
        <tr>
            {% for key,cell in row %}
            {% if key not in skip %}
            <td>{{cell|raw}}</td>
            {% endif %}
            {% endfor %}
        </tr>
        {% endfor %}
    </tbody>
</table>
{% else %}
<p>Il n'y a pas de donnes qui correspondent au vos criteres.</p>
{% endif %}
{% endmacro %}

{% macro dumptablelinked(tbl, skip = []) %}
{% if tbl|length > 0 %}
<table class="table table-linked">
    <thead>
        <tr>
            {% for key, _ in tbl[0] %}
            {% if key != '_href' and key not in skip %}
            <th>{{lang(key)|raw}}</th>
            {% endif %}
            {% endfor %}
        </tr>
    </thead>

    <tbody>
        {% for row in tbl %}
        <tr href="{{row['_href']}}">
            {% for key, cell in row %}
            {% if key != '_href' and key not in skip %}
            <td>{{cell|raw}}</td>
            {% endif %}
            {% endfor %}
        </tr>
        {% endfor %}
    </tbody>
</table>
{% else %}
<p>Il n'y a pas de donnes qui correspondent au vos criteres.</p>
{% endif %}
{% endmacro %}

{% macro btn(lbl, route, args = {}) %}
<a href="{{ urlFor(route, args) }}" class="btn">
    {{lbl}}
</a>
{% endmacro %}
